const { query } = require("./mysql");
const { YD_datetimeToString, YD_whereSql } = require("lib/utils/common");

/** @name 套餐列表 **/
exports.yd_list = () => {
	const sql = `select *,
						${YD_datetimeToString("createTime")},
						${YD_datetimeToString("updateTime")}
						from ch_package
            `;
	return query(sql);
};

/** @name 查询套餐信息-id **/
exports.yd_find = (options) => {
	const sql = `select
						*,
						${YD_datetimeToString("createTime")},
						${YD_datetimeToString("updateTime")}
						from ch_package
						${YD_whereSql([{ field: "id", type: "全等", value: options.id }])}
						`;
	return query(sql);
};

/** @name 查询套餐信息-code **/
exports.yd_findCode = (options) => {
	const sql = `select
						*,
						${YD_datetimeToString("createTime")},
						${YD_datetimeToString("updateTime")}
						from ch_package
						${YD_whereSql([{ field: "code", type: "全等", value: options.code }])}
						`;
	return query(sql);
};
